/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "QLTTB_ORGAO_USINA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrgaoUsina.findAll", query = "SELECT o FROM OrgaoUsina o ORDER BY o.ousId"),
    @NamedQuery(name = "OrgaoUsina.findByOusId", query = "SELECT o FROM OrgaoUsina o WHERE o.ousId = :ousId"),
    @NamedQuery(name = "OrgaoUsina.findByOusOrgId", query = "SELECT o FROM OrgaoUsina o WHERE o.ousOrgId = :ousOrgId"),
    @NamedQuery(name = "OrgaoUsina.findByOusUsiId", query = "SELECT o FROM OrgaoUsina o WHERE o.ousUsiId = :ousUsiId"),
    @NamedQuery(name = "OrgaoUsina.findOrgaoUsinaByUsina", query = "SELECT o FROM OrgaoUsina o WHERE o.ousUsiId = :ousUsiId"),
    @NamedQuery(name = "OrgaoUsina.deleteOrgaoUsinaByUsina", query = "DELETE FROM OrgaoUsina o WHERE o.ousUsiId = :ousUsiId")})
@SequenceGenerator(name = "sequenceOrgaoUsina", sequenceName = "SQ_QLTTB_ORGAO_USINA", allocationSize = 1)
public class OrgaoUsina implements Serializable {

    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "OUS_ID")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceOrgaoUsina")
    private BigDecimal ousId;
    @JoinColumn(name = "OUS_ORG_ID", referencedColumnName = "ORG_ID")
    @ManyToOne
    private Orgao ousOrgId;
    @JoinColumn(name = "OUS_USI_ID", referencedColumnName = "USI_ID")
    @ManyToOne
    private Usina ousUsiId;

    public OrgaoUsina() {
    }

    public OrgaoUsina(BigDecimal ousId) {
        this.ousId = ousId;
    }

    public BigDecimal getOusId() {
        return ousId;
    }

    public void setOusId(BigDecimal ousId) {
        this.ousId = ousId;
    }

    public Orgao getOusOrgId() {
        return ousOrgId;
    }

    public void setOusOrgId(Orgao ousOrgId) {
        this.ousOrgId = ousOrgId;
    }

    public Usina getOusUsiId() {
        return ousUsiId;
    }

    public void setOusUsiId(Usina ousUsiId) {
        this.ousUsiId = ousUsiId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ousId != null ? ousId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrgaoUsina)) {
            return false;
        }
        OrgaoUsina other = (OrgaoUsina) object;
        if ((this.ousId == null && other.ousId != null) || (this.ousId != null && !this.ousId.equals(other.ousId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "" + this.ousId;
    }
}
